package com.sysu.minsysu.zdkb.utils;

import java.io.Serializable;

import android.text.format.Time;

public class Course implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 8943393805823061580L;
	int id;
	String courseName;
	String teacherName;
	int weekStart;
	int weekLast;
	int date;
	int timeStart;
	int classCount;
	String campus;
	String building;
	int room;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getCourseName() {
		return courseName;
	}
	public void setCourseName(String courseName) {
		this.courseName = courseName;
	}
	public String getTeacherName() {
		return teacherName;
	}
	public void setTeacherName(String teacherName) {
		this.teacherName = teacherName;
	}
	public int getWeekStart() {
		return weekStart;
	}
	public void setWeekStart(int weekStart) {
		this.weekStart = weekStart;
	}
	public int getWeekLast() {
		return weekLast;
	}
	public void setWeekLast(int weekLast) {
		this.weekLast = weekLast;
	}
	public int getDateOfNumber(){
		return date;
	}
	public String getDate() {
		String str="星期";
		switch (date) {
		case 1:
			return str+"一";
		case 2:
			return str+"二";
		case 3:
			return str+"三";
		case 4:
			return str+"四";
		case 5:
			return str+"五";
		case 6:
			return str+"六";
		case 7:
			return str+"日";

		default:
			return null;
		}
	}
	public void setDate(int date) {
		this.date = date;
	}
	public String getClassInterval(){
		return timeStart + "-" + (timeStart+classCount-1) + "节";
	}
	public String getTimeInterval(){
		Time start = CourseUtils.classTimeConverter(timeStart);
		Time end = CourseUtils.classTimeConverter(timeStart+classCount-1, true);
		return start.hour + ":" + start.minute + "-" + end.hour + ":" + end.minute;
		
	}
	public int getTimeStart() {
		return timeStart;
	}
	public int getTimeEnd(){
		return timeStart+classCount-1;
	}
	public void setTimeStart(int timeStart) {
		this.timeStart = timeStart;
	}
	public int getClassCount() {
		return classCount;
	}
	public void setClassCount(int classCount) {
		this.classCount = classCount;
	}
	public String getCampus() {
		return campus;
	}
	public void setCampus(String campus) {
		this.campus = campus;
	}
	public String getPlace() {
		return building+" " + room;
	}
			
	public String getBuilding() {
		return building;
	}
	public void setBuilding(String building) {
		this.building = building;
	}
	public int getRoom() {
		return room;
	}
	public void setRoom(int room) {
		this.room = room;
	}
	public boolean conflictTest( Course other ){
		if( date!=other.date )
			return false;
		if( timeStart > other.timeStart+other.classCount-1 || timeStart+classCount-1 < other.timeStart )
			return false;
		return true;
	}
	
	@Override
	public boolean equals(Object c ){
		if( ! ( c instanceof Course ) )
			return false;
		Course course = (Course)c;
		if( course.courseName.equals(courseName) && course.teacherName.equals(teacherName) && course.date == date && course.timeStart == timeStart )
			return true;
		else 
			return false;
	}
}
